<?php

class usuario extends FDefaultModel
{
    public function __construct()
    {
        parent::__construct('usuario');
    }

    public function getForm()
    {
        $editForm = new FEditForm();
        
        $fields['login'] = new FTextField('login', 'Login', 50);
        $fields['login']->setRequired(true);
        $fields['login']->setMaxLength(32);
        $fields['nome'] = new FTextField('nome', 'Nome', 80);
        $fields['nome']->setRequired(true);
        /*$fields['senha'] = new FPasswordField('senha', 'Senha', 60);
        $fields['senha']->setRequired(true);*/
        
        $fields[] = $detail = new FDetail('papel_usuario', 'Papéis do usuário', 'usuario', 'papel');
        
        $colunas['codigo'] = new FGridColumn('Cód. papel', 10);
        $colunas['codigo']->setHidden(true);
        $colunas['descricao'] = new FGridColumn('Papel', '94%');
        $campos[] = $sel = new FSelection('cod_papel', 'Papel');
        $sel->setTable('papel');
        $sel->setRequired(true);
        $detail->setGridColumns($colunas);
        $detail->setFormFields($campos);
        
        $editForm->setFormFields($fields);
        $editForm->setWidth(450);
        $editForm->setHeight(600);
        $editForm->setAction(FEditForm::FUNCTION_UPDATE);
        $this->setEditForm($editForm);
        
        
        $insertForm = new FEditForm();
        $insertForm->setFormFields($fields);
        $insertForm->setWidth(450);
        $insertForm->setHeight(600);
        $this->setInsertForm($insertForm);
        
        return parent::getForm();
    }
}

?>
